package org.szy.plugin.gen.enums;


/**
 * 表前缀移除枚举
 *
 * @author 孙志阳
 * @date 2023-02-12
 * @since 1.0.0
 **/
public enum GenTablePrefixEnum {

    /**
     * 压缩包
     */
    ZIP(1, "移除"),

    /**
     * 项目内
     */
    PRO(2, "不移除");

    private final int code;
    private final String value;

    GenTablePrefixEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    /**
     * 根据value查找
     *
     * @param code 数据值
     * @return 枚举对象
     */
    public static GenTablePrefixEnum findByCode(Integer code) {
        for (GenTablePrefixEnum statusEnum : GenTablePrefixEnum.values()) {
            if (statusEnum.getCode() == code) {
                return statusEnum;
            }
        }
        throw new IllegalArgumentException("code is invalid");
    }


    /**
     * 根据value查找
     *
     * @param value 枚举value
     * @return 枚举对象
     */
    public static GenTablePrefixEnum findByValue(String value) {
        for (GenTablePrefixEnum statusEnum : GenTablePrefixEnum.values()) {
            if (statusEnum.getValue().equals(value)) {
                return statusEnum;
            }
        }
        throw new IllegalArgumentException("value is invalid");
    }

    public int getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }
}
